<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>JavaScript常用方法 | Joey</title><meta name="keywords" content="JavaScript"><meta name="author" content="方陈勇"><meta name="copyright" content="方陈勇"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="JavaScript常用方法工作过程中使用记录">
<meta property="og:type" content="article">
<meta property="og:title" content="JavaScript常用方法">
<meta property="og:url" content="http://fangchenyong.top/2019/10/29/JS-JS%E5%B8%B8%E7%94%A8%E6%96%B9%E6%B3%95/index.html">
<meta property="og:site_name" content="Joey">
<meta property="og:description" content="JavaScript常用方法工作过程中使用记录">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://fangchenyong.oss-cn-hangzhou.aliyuncs.com/BEF238F4E59CF4D91A694FE9C5DBC030.JPG">
<meta property="article:published_time" content="2019-10-29T14:12:23.000Z">
<meta property="article:modified_time" content="2020-05-22T09:59:30.881Z">
<meta property="article:author" content="方陈勇">
<meta property="article:tag" content="JavaScript">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://fangchenyong.oss-cn-hangzhou.aliyuncs.com/BEF238F4E59CF4D91A694FE9C5DBC030.JPG"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="http://fangchenyong.top/2019/10/29/JS-JS%E5%B8%B8%E7%94%A8%E6%96%B9%E6%B3%95/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isanchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = { 
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2020-05-22 17:59:30'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    })(window)</script><meta name="generator" content="Hexo 5.4.0"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="author-avatar"><img class="avatar-img" src="https://fangchenyong.oss-cn-hangzhou.aliyuncs.com/3FD9B055-6361-49B7-B8CE-5BA9144BD27F.JPG" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">文章</div><div class="length-num">40</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">标签</div><div class="length-num">47</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/categories/"><div class="headline">分类</div><div class="length-num">49</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> Home</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> Archives</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> Tags</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> Categories</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> List</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/music/"><i class="fa-fw fas fa-music"></i><span> Music</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> Movie</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> Link</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> About</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://fangchenyong.oss-cn-hangzhou.aliyuncs.com/BEF238F4E59CF4D91A694FE9C5DBC030.JPG')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">Joey</a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> Home</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> Archives</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> Tags</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> Categories</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> List</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/music/"><i class="fa-fw fas fa-music"></i><span> Music</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> Movie</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> Link</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> About</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">JavaScript常用方法</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2019-10-29T14:12:23.000Z" title="发表于 2019-10-29 22:12:23">2019-10-29</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2020-05-22T09:59:30.881Z" title="更新于 2020-05-22 17:59:30">2020-05-22</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/JavaScript/">JavaScript</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">1.1k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>6分钟</span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="JavaScript常用方法"><a href="#JavaScript常用方法" class="headerlink" title="JavaScript常用方法"></a>JavaScript常用方法</h1><h2 id="1-将数值四舍五入-保留2位小数-后格式化成金额形式"><a href="#1-将数值四舍五入-保留2位小数-后格式化成金额形式" class="headerlink" title="1. 将数值四舍五入(保留2位小数)后格式化成金额形式"></a>1. 将数值四舍五入(保留2位小数)后格式化成金额形式</h2><figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 将数值四舍五入(保留2位小数)后格式化成金额形式</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param </span>num 数值(Number或者String)</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@return </span>金额格式的字符串,如&#x27;1,234,567.45&#x27;</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@type <span class="variable">String</span></span></span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">formatCurrency</span>(<span class="params">num</span>) </span>&#123;</span><br><span class="line">    num = num.toString().replace(<span class="regexp">/\$|\,/g</span>,<span class="string">&#x27;&#x27;</span>);</span><br><span class="line">    <span class="keyword">if</span>(<span class="built_in">isNaN</span>(num))</span><br><span class="line">        num = <span class="string">&quot;0&quot;</span>;</span><br><span class="line">    sign = (num == (num = <span class="built_in">Math</span>.abs(num)));</span><br><span class="line">    num = <span class="built_in">Math</span>.floor(num*<span class="number">100</span>+<span class="number">0.50000000001</span>);</span><br><span class="line">    cents = num%<span class="number">100</span>;</span><br><span class="line">    num = <span class="built_in">Math</span>.floor(num/<span class="number">100</span>).toString();</span><br><span class="line">    <span class="keyword">if</span>(cents&lt;<span class="number">10</span>)</span><br><span class="line">    cents = <span class="string">&quot;0&quot;</span> + cents;</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">var</span> i = <span class="number">0</span>; i &lt; <span class="built_in">Math</span>.floor((num.length-(<span class="number">1</span>+i))/<span class="number">3</span>); i++)</span><br><span class="line">    num = num.substring(<span class="number">0</span>,num.length-(<span class="number">4</span>*i+<span class="number">3</span>))+<span class="string">&#x27;,&#x27;</span>+</span><br><span class="line">    num.substring(num.length-(<span class="number">4</span>*i+<span class="number">3</span>));</span><br><span class="line">    <span class="keyword">return</span> (((sign)?<span class="string">&#x27;&#x27;</span>:<span class="string">&#x27;-&#x27;</span>) + num + <span class="string">&#x27;.&#x27;</span> + cents);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="2-金额转大写"><a href="#2-金额转大写" class="headerlink" title="2. 金额转大写"></a>2. 金额转大写</h2><figure class="highlight javascript"><table><tr><td class="code"><pre><span class="line"><span class="comment">//金额转大写</span></span><br><span class="line"><span class="keyword">var</span> digitUppercase = <span class="function"><span class="keyword">function</span> (<span class="params">n</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">var</span> fraction = [<span class="string">&#x27;角&#x27;</span>, <span class="string">&#x27;分&#x27;</span>];</span><br><span class="line">    <span class="keyword">var</span> digit = [</span><br><span class="line">        <span class="string">&#x27;零&#x27;</span>, <span class="string">&#x27;壹&#x27;</span>, <span class="string">&#x27;贰&#x27;</span>, <span class="string">&#x27;叁&#x27;</span>, <span class="string">&#x27;肆&#x27;</span>,</span><br><span class="line">        <span class="string">&#x27;伍&#x27;</span>, <span class="string">&#x27;陆&#x27;</span>, <span class="string">&#x27;柒&#x27;</span>, <span class="string">&#x27;捌&#x27;</span>, <span class="string">&#x27;玖&#x27;</span></span><br><span class="line">    ];</span><br><span class="line">    <span class="keyword">var</span> unit = [</span><br><span class="line">        [<span class="string">&#x27;元&#x27;</span>, <span class="string">&#x27;万&#x27;</span>, <span class="string">&#x27;亿&#x27;</span>],</span><br><span class="line">        [<span class="string">&#x27;&#x27;</span>, <span class="string">&#x27;拾&#x27;</span>, <span class="string">&#x27;佰&#x27;</span>, <span class="string">&#x27;仟&#x27;</span>]</span><br><span class="line">    ];</span><br><span class="line">    <span class="keyword">var</span> head = n &lt; <span class="number">0</span> ? <span class="string">&#x27;欠&#x27;</span> : <span class="string">&#x27;&#x27;</span>;</span><br><span class="line">    n = <span class="built_in">Math</span>.abs(n);</span><br><span class="line">    <span class="keyword">var</span> s = <span class="string">&#x27;&#x27;</span>;</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">var</span> i = <span class="number">0</span>; i &lt; fraction.length; i++) &#123;</span><br><span class="line">        s += (digit[<span class="built_in">Math</span>.floor(n * <span class="number">10</span> * <span class="built_in">Math</span>.pow(<span class="number">10</span>, i)) % <span class="number">10</span>] + fraction[i]).replace(<span class="regexp">/零./</span>, <span class="string">&#x27;&#x27;</span>);</span><br><span class="line">    &#125;</span><br><span class="line">    s = s || <span class="string">&#x27;整&#x27;</span>;</span><br><span class="line">    n = <span class="built_in">Math</span>.floor(n);</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">var</span> i = <span class="number">0</span>; i &lt; unit[<span class="number">0</span>].length &amp;&amp; n &gt; <span class="number">0</span>; i++) &#123;</span><br><span class="line">        <span class="keyword">var</span> p = <span class="string">&#x27;&#x27;</span>;</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">var</span> j = <span class="number">0</span>; j &lt; unit[<span class="number">1</span>].length &amp;&amp; n &gt; <span class="number">0</span>; j++) &#123;</span><br><span class="line">            p = digit[n % <span class="number">10</span>] + unit[<span class="number">1</span>][j] + p;</span><br><span class="line">            n = <span class="built_in">Math</span>.floor(n / <span class="number">10</span>);</span><br><span class="line">        &#125;</span><br><span class="line">        s = p.replace(<span class="regexp">/(零.)*零$/</span>, <span class="string">&#x27;&#x27;</span>).replace(<span class="regexp">/^$/</span>, <span class="string">&#x27;零&#x27;</span>) + unit[<span class="number">0</span>][i] + s;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> head + s.replace(<span class="regexp">/(零.)*零元/</span>, <span class="string">&#x27;元&#x27;</span>)</span><br><span class="line">        .replace(<span class="regexp">/(零.)+/g</span>, <span class="string">&#x27;零&#x27;</span>)</span><br><span class="line">        .replace(<span class="regexp">/^整$/</span>, <span class="string">&#x27;零元整&#x27;</span>);</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>

<h2 id="3-计算文件大小"><a href="#3-计算文件大小" class="headerlink" title="3. 计算文件大小"></a>3. 计算文件大小</h2><figure class="highlight javascript"><table><tr><td class="code"><pre><span class="line"><span class="comment">// 计算文件大小函数(保留两位小数),Size为字节大小</span></span><br><span class="line"><span class="comment">// size：初始文件大小</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">getfilesize</span>(<span class="params">size</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">if</span> (!size)</span><br><span class="line">        <span class="keyword">return</span> <span class="string">&quot;&quot;</span>;</span><br><span class="line">    <span class="keyword">var</span> num = <span class="number">1024.00</span>; <span class="comment">//byte</span></span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> (size &lt; num)</span><br><span class="line">        <span class="keyword">return</span> size + <span class="string">&quot;B&quot;</span>;</span><br><span class="line">    <span class="keyword">if</span> (size &lt; <span class="built_in">Math</span>.pow(num, <span class="number">2</span>))</span><br><span class="line">        <span class="keyword">return</span> (size / num).toFixed(<span class="number">2</span>) + <span class="string">&quot;K&quot;</span>; <span class="comment">//kb</span></span><br><span class="line">    <span class="keyword">if</span> (size &lt; <span class="built_in">Math</span>.pow(num, <span class="number">3</span>))</span><br><span class="line">        <span class="keyword">return</span> (size / <span class="built_in">Math</span>.pow(num, <span class="number">2</span>)).toFixed(<span class="number">2</span>) + <span class="string">&quot;M&quot;</span>; <span class="comment">//M</span></span><br><span class="line">    <span class="keyword">if</span> (size &lt; <span class="built_in">Math</span>.pow(num, <span class="number">4</span>))</span><br><span class="line">        <span class="keyword">return</span> (size / <span class="built_in">Math</span>.pow(num, <span class="number">3</span>)).toFixed(<span class="number">2</span>) + <span class="string">&quot;G&quot;</span>; <span class="comment">//G</span></span><br><span class="line">    <span class="keyword">return</span> (size / <span class="built_in">Math</span>.pow(num, <span class="number">4</span>)).toFixed(<span class="number">2</span>) + <span class="string">&quot;T&quot;</span>; <span class="comment">//T</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="4-获取输入框选中值"><a href="#4-获取输入框选中值" class="headerlink" title="4. 获取输入框选中值"></a>4. 获取输入框选中值</h2><figure class="highlight javascript"><table><tr><td class="code"><pre><span class="line">&lt;body&gt;</span><br><span class="line">&lt;input type=<span class="string">&quot;text&quot;</span> id=<span class="string">&quot;dxs&quot;</span> name=<span class="string">&quot;name&quot;</span> /&gt;</span><br><span class="line">&lt;input type=<span class="string">&quot;button&quot;</span> value=<span class="string">&quot;获取&quot;</span>  onclick=<span class="string">&quot;getSelectedText()&quot;</span>&gt;</span><br><span class="line">&lt;script&gt;</span><br><span class="line">	<span class="function"><span class="keyword">function</span> <span class="title">getSelectedText</span>(<span class="params"></span>)</span>&#123;  </span><br><span class="line">	<span class="keyword">var</span> inputDom =  <span class="built_in">document</span>.getElementById(<span class="string">&quot;dxs&quot;</span>);</span><br><span class="line">    <span class="keyword">if</span> (<span class="built_in">document</span>.selection) <span class="comment">//IE</span></span><br><span class="line">    &#123; </span><br><span class="line">        alert(<span class="built_in">document</span>.selection.createRange().text); </span><br><span class="line">    &#125;  </span><br><span class="line">    <span class="keyword">else</span> &#123;  </span><br><span class="line">        alert(inputDom.value.substring(inputDom.selectionStart,  </span><br><span class="line">                inputDom.selectionEnd));  </span><br><span class="line">    &#125;  </span><br><span class="line">&#125;</span><br><span class="line">&lt;/script&gt;</span><br><span class="line">&lt;/body&gt;</span><br></pre></td></tr></table></figure>

<h2 id="5-判断对象是不是数组"><a href="#5-判断对象是不是数组" class="headerlink" title="5. 判断对象是不是数组"></a>5. 判断对象是不是数组</h2><figure class="highlight javascript"><table><tr><td class="code"><pre><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">isArray</span>(<span class="params">source</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">return</span> <span class="string">&#x27;[object Array]&#x27;</span> == <span class="built_in">Object</span>.prototype.toString.call(source);</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>

<h2 id="6-获取url根路径"><a href="#6-获取url根路径" class="headerlink" title="6. 获取url根路径"></a>6. 获取url根路径</h2><figure class="highlight javascript"><table><tr><td class="code"><pre><span class="line"><span class="comment">//例如  http://12.3.4.5/joey/</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">getRootPath</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">    <span class="keyword">var</span> strFullPath = <span class="built_in">window</span>.document.location.href;</span><br><span class="line">    <span class="keyword">var</span> strPath = <span class="built_in">window</span>.document.location.pathname;</span><br><span class="line">    <span class="keyword">var</span> pos = strFullPath.indexOf(strPath);</span><br><span class="line">    <span class="keyword">var</span> prePath = strFullPath.substring(<span class="number">0</span>, pos);</span><br><span class="line">    <span class="keyword">var</span> postPath = strPath.substring(<span class="number">0</span>, strPath.substr(<span class="number">1</span>).indexOf(<span class="string">&#x27;/&#x27;</span>) + <span class="number">1</span>);</span><br><span class="line">    <span class="keyword">return</span> (prePath + postPath);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="7-获取url指定参数"><a href="#7-获取url指定参数" class="headerlink" title="7. 获取url指定参数"></a>7. 获取url指定参数</h2><figure class="highlight javascript"><table><tr><td class="code"><pre><span class="line"><span class="comment">//strParame为参数名称,url为地址</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">request</span>(<span class="params">strParame, url</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">var</span> args = <span class="keyword">new</span> <span class="built_in">Object</span>();</span><br><span class="line">    <span class="keyword">var</span> query = <span class="string">&quot;&quot;</span>;</span><br><span class="line">    <span class="keyword">if</span> (!url)</span><br><span class="line">        query = <span class="built_in">unescape</span>(location.search.substring(<span class="number">1</span>)); <span class="comment">// Get query string</span></span><br><span class="line">    <span class="keyword">else</span> &#123;</span><br><span class="line">        <span class="keyword">var</span> index = url.indexOf(<span class="string">&quot;?&quot;</span>);</span><br><span class="line">        query = url.substring(index + <span class="number">1</span>);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">var</span> pairs = query.split(<span class="string">&quot;&amp;&quot;</span>); <span class="comment">// Break at ampersand</span></span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">var</span> i = <span class="number">0</span>; i &lt; pairs.length; i++) &#123;</span><br><span class="line">        <span class="keyword">var</span> pos = pairs[i].indexOf(<span class="string">&#x27;=&#x27;</span>); <span class="comment">// Look for &quot;name=value&quot;</span></span><br><span class="line">        <span class="keyword">if</span> (pos == -<span class="number">1</span>) <span class="keyword">continue</span>; <span class="comment">// If not found, skip</span></span><br><span class="line">        <span class="keyword">var</span> argname = pairs[i].substring(<span class="number">0</span>, pos); <span class="comment">// Extract the name</span></span><br><span class="line">        <span class="keyword">var</span> value = pairs[i].substring(pos + <span class="number">1</span>); <span class="comment">// Extract the value</span></span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            value = <span class="built_in">decodeURIComponent</span>(value); <span class="comment">// Decode it, if needed</span></span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">catch</span> (e) &#123; &#125;</span><br><span class="line">        args[argname] = value; <span class="comment">// Store as a property</span></span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> args[strParame]; <span class="comment">// Return the object</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="8-创建GUID"><a href="#8-创建GUID" class="headerlink" title="8. 创建GUID"></a>8. 创建GUID</h2><figure class="highlight javascript"><table><tr><td class="code"><pre><span class="line"><span class="comment">//补了零的标准的guid格式（当然多了个“guid_”前缀,以及使用“_”代替“-”）。</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">CreateGUID</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">function</span> <span class="title">s4</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="built_in">Math</span>.floor((<span class="number">1</span> + <span class="built_in">Math</span>.random()) * <span class="number">0x10000</span>)</span><br><span class="line">          .toString(<span class="number">16</span>)</span><br><span class="line">          .substring(<span class="number">1</span>);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> s4() + s4() + <span class="string">&#x27;-&#x27;</span> + s4() + <span class="string">&#x27;-&#x27;</span> + s4() + <span class="string">&#x27;-&#x27;</span> +</span><br><span class="line">      s4() + <span class="string">&#x27;-&#x27;</span> + s4() + s4() + s4();</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="9-判断一个值是否为空"><a href="#9-判断一个值是否为空" class="headerlink" title="9. 判断一个值是否为空"></a>9. 判断一个值是否为空</h2><figure class="highlight javascript"><table><tr><td class="code"><pre><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">IsEmpty</span>(<span class="params">value</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">if</span> (value == <span class="literal">undefined</span>) <span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line">    <span class="keyword">if</span> (value == <span class="literal">null</span>) <span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line">    <span class="keyword">if</span> (value == <span class="string">&quot;&quot;</span>) <span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line">    <span class="keyword">if</span> (value == <span class="string">&quot;00000000-0000-0000-0000-000000000000&quot;</span>) <span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line">    <span class="keyword">return</span> <span class="literal">false</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="10-设置cookie"><a href="#10-设置cookie" class="headerlink" title="10. 设置cookie"></a>10. 设置cookie</h2><figure class="highlight javascript"><table><tr><td class="code"><pre><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">setCookie</span>(<span class="params">name, value</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">var</span> Days = <span class="number">300</span>; <span class="comment">//此 cookie 将被保存 30 天</span></span><br><span class="line">    <span class="keyword">var</span> exp = <span class="keyword">new</span> <span class="built_in">Date</span>();    <span class="comment">//new Date(&quot;December 31, 9998&quot;);</span></span><br><span class="line">    exp.setTime(exp.getTime() + Days * <span class="number">24</span> * <span class="number">60</span> * <span class="number">60</span> * <span class="number">1000</span>);</span><br><span class="line">    <span class="built_in">document</span>.cookie = name + <span class="string">&quot;=&quot;</span> + <span class="built_in">escape</span>(value) + <span class="string">&quot;;expires=&quot;</span> + exp.toGMTString();</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="11-获取cookie"><a href="#11-获取cookie" class="headerlink" title="11. 获取cookie"></a>11. 获取cookie</h2><figure class="highlight javascript"><table><tr><td class="code"><pre><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">getCookie</span>(<span class="params">name</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">var</span> arr = <span class="built_in">document</span>.cookie.match(<span class="keyword">new</span> <span class="built_in">RegExp</span>(<span class="string">&quot;(^| )&quot;</span> + name + <span class="string">&quot;=([^;]*)(;|$)&quot;</span>));</span><br><span class="line">    <span class="keyword">if</span> (arr != <span class="literal">null</span>) <span class="keyword">return</span> <span class="built_in">unescape</span>(arr[<span class="number">2</span>]); <span class="keyword">return</span> <span class="string">&quot;&quot;</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="12-删除cookie"><a href="#12-删除cookie" class="headerlink" title="12. 删除cookie"></a>12. 删除cookie</h2><figure class="highlight javascript"><table><tr><td class="code"><pre><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">delCookie</span>(<span class="params">name</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">var</span> exp = <span class="keyword">new</span> <span class="built_in">Date</span>();</span><br><span class="line">    exp.setTime(exp.getTime() - <span class="number">1</span>);</span><br><span class="line">    <span class="keyword">var</span> cval = getCookie(name);</span><br><span class="line">    <span class="keyword">if</span> (cval != <span class="literal">null</span>)</span><br><span class="line">        <span class="built_in">document</span>.cookie = name + <span class="string">&quot;=&quot;</span> + cval + <span class="string">&quot;;expires=&quot;</span> + exp.toGMTString();</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="13-对象数组去重"><a href="#13-对象数组去重" class="headerlink" title="13. 对象数组去重"></a>13. 对象数组去重</h2><figure class="highlight javascript"><table><tr><td class="code"><pre><span class="line"><span class="comment">//对connects进行去重，el.pageSourceId == element.pageSourceId是去重条件</span></span><br><span class="line"><span class="keyword">var</span> connects = connects.reduce(<span class="function"><span class="keyword">function</span> (<span class="params">prev, element</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">if</span> (!prev.find(<span class="function"><span class="params">el</span>=&gt;</span>(el.pageSourceId == element.pageSourceId))) &#123;</span><br><span class="line">        prev.push(element)</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> prev</span><br><span class="line">&#125;, []);</span><br></pre></td></tr></table></figure>

</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">方陈勇</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="http://fangchenyong.top/2019/10/29/JS-JS%E5%B8%B8%E7%94%A8%E6%96%B9%E6%B3%95/">http://fangchenyong.top/2019/10/29/JS-JS%E5%B8%B8%E7%94%A8%E6%96%B9%E6%B3%95/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="http://fangchenyong.top" target="_blank">Joey</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/JavaScript/">JavaScript</a></div><div class="post_share"><div class="social-share" data-image="https://fangchenyong.oss-cn-hangzhou.aliyuncs.com/BEF238F4E59CF4D91A694FE9C5DBC030.JPG" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2019/11/06/JS-JsPlumb%E7%BB%98%E5%88%B6%E6%B5%81%E7%A8%8B%E5%9B%BE/"><img class="prev-cover" src="https://fangchenyong.oss-cn-hangzhou.aliyuncs.com/BEF238F4E59CF4D91A694FE9C5DBC030.JPG" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">jsplumb绘制流程图</div></div></a></div><div class="next-post pull-right"><a href="/2019/10/15/%E5%9C%B0%E5%9B%BE-%E8%85%BE%E8%AE%AF%E5%9C%B0%E5%9B%BE%E5%9D%90%E6%A0%87%E6%8B%BE%E5%8F%96%E5%99%A8/"><img class="next-cover" src="https://fangchenyong.oss-cn-hangzhou.aliyuncs.com/BEF238F4E59CF4D91A694FE9C5DBC030.JPG" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">腾讯地图坐标选取器</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span> 相关推荐</span></div><div class="relatedPosts-list"><div><a href="/2019/11/06/JS-JsPlumb绘制流程图/" title="jsplumb绘制流程图"><img class="cover" src="https://fangchenyong.oss-cn-hangzhou.aliyuncs.com/BEF238F4E59CF4D91A694FE9C5DBC030.JPG" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2019-11-06</div><div class="title">jsplumb绘制流程图</div></div></a></div><div><a href="/2019/07/25/JS-二维码扫描下载APP/" title="二维码扫描下载APP页面"><img class="cover" src="https://fangchenyong.oss-cn-hangzhou.aliyuncs.com/BEF238F4E59CF4D91A694FE9C5DBC030.JPG" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2019-07-25</div><div class="title">二维码扫描下载APP页面</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="card-info-avatar is-center"><img class="avatar-img" src="https://fangchenyong.oss-cn-hangzhou.aliyuncs.com/3FD9B055-6361-49B7-B8CE-5BA9144BD27F.JPG" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/><div class="author-info__name">方陈勇</div><div class="author-info__description">一路向前</div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">40</div></a></div><div class="card-info-data-item is-center"><a href="/tags/"><div class="headline">标签</div><div class="length-num">47</div></a></div><div class="card-info-data-item is-center"><a href="/categories/"><div class="headline">分类</div><div class="length-num">49</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/fangchenyong"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/fangchenyong" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:1013659102@qq.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">个人笔记，如有疑问请联系 QQ:1013659102。</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#JavaScript%E5%B8%B8%E7%94%A8%E6%96%B9%E6%B3%95"><span class="toc-number">1.</span> <span class="toc-text">JavaScript常用方法</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#1-%E5%B0%86%E6%95%B0%E5%80%BC%E5%9B%9B%E8%88%8D%E4%BA%94%E5%85%A5-%E4%BF%9D%E7%95%992%E4%BD%8D%E5%B0%8F%E6%95%B0-%E5%90%8E%E6%A0%BC%E5%BC%8F%E5%8C%96%E6%88%90%E9%87%91%E9%A2%9D%E5%BD%A2%E5%BC%8F"><span class="toc-number">1.1.</span> <span class="toc-text">1. 将数值四舍五入(保留2位小数)后格式化成金额形式</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-%E9%87%91%E9%A2%9D%E8%BD%AC%E5%A4%A7%E5%86%99"><span class="toc-number">1.2.</span> <span class="toc-text">2. 金额转大写</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-%E8%AE%A1%E7%AE%97%E6%96%87%E4%BB%B6%E5%A4%A7%E5%B0%8F"><span class="toc-number">1.3.</span> <span class="toc-text">3. 计算文件大小</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4-%E8%8E%B7%E5%8F%96%E8%BE%93%E5%85%A5%E6%A1%86%E9%80%89%E4%B8%AD%E5%80%BC"><span class="toc-number">1.4.</span> <span class="toc-text">4. 获取输入框选中值</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#5-%E5%88%A4%E6%96%AD%E5%AF%B9%E8%B1%A1%E6%98%AF%E4%B8%8D%E6%98%AF%E6%95%B0%E7%BB%84"><span class="toc-number">1.5.</span> <span class="toc-text">5. 判断对象是不是数组</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#6-%E8%8E%B7%E5%8F%96url%E6%A0%B9%E8%B7%AF%E5%BE%84"><span class="toc-number">1.6.</span> <span class="toc-text">6. 获取url根路径</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#7-%E8%8E%B7%E5%8F%96url%E6%8C%87%E5%AE%9A%E5%8F%82%E6%95%B0"><span class="toc-number">1.7.</span> <span class="toc-text">7. 获取url指定参数</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#8-%E5%88%9B%E5%BB%BAGUID"><span class="toc-number">1.8.</span> <span class="toc-text">8. 创建GUID</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#9-%E5%88%A4%E6%96%AD%E4%B8%80%E4%B8%AA%E5%80%BC%E6%98%AF%E5%90%A6%E4%B8%BA%E7%A9%BA"><span class="toc-number">1.9.</span> <span class="toc-text">9. 判断一个值是否为空</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#10-%E8%AE%BE%E7%BD%AEcookie"><span class="toc-number">1.10.</span> <span class="toc-text">10. 设置cookie</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#11-%E8%8E%B7%E5%8F%96cookie"><span class="toc-number">1.11.</span> <span class="toc-text">11. 获取cookie</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#12-%E5%88%A0%E9%99%A4cookie"><span class="toc-number">1.12.</span> <span class="toc-text">12. 删除cookie</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#13-%E5%AF%B9%E8%B1%A1%E6%95%B0%E7%BB%84%E5%8E%BB%E9%87%8D"><span class="toc-number">1.13.</span> <span class="toc-text">13. 对象数组去重</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/2021/03/21/%E9%9D%A2%E8%AF%95-%E5%B9%B6%E5%8F%91%E3%80%81%E5%A4%9A%E7%BA%BF%E7%A8%8B/" title="面试题-并发编程"><img src="https://fangchenyong.oss-cn-hangzhou.aliyuncs.com/BEF238F4E59CF4D91A694FE9C5DBC030.JPG" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="面试题-并发编程"/></a><div class="content"><a class="title" href="/2021/03/21/%E9%9D%A2%E8%AF%95-%E5%B9%B6%E5%8F%91%E3%80%81%E5%A4%9A%E7%BA%BF%E7%A8%8B/" title="面试题-并发编程">面试题-并发编程</a><time datetime="2021-03-20T16:00:00.000Z" title="发表于 2021-03-21 00:00:00">2021-03-21</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/03/20/%E9%9D%A2%E8%AF%95-%E9%9B%86%E5%90%88/" title="面试题-集合框架"><img src="https://fangchenyong.oss-cn-hangzhou.aliyuncs.com/BEF238F4E59CF4D91A694FE9C5DBC030.JPG" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="面试题-集合框架"/></a><div class="content"><a class="title" href="/2021/03/20/%E9%9D%A2%E8%AF%95-%E9%9B%86%E5%90%88/" title="面试题-集合框架">面试题-集合框架</a><time datetime="2021-03-19T16:00:00.000Z" title="发表于 2021-03-20 00:00:00">2021-03-20</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/03/20/Java-%E6%BA%90%E7%A0%81-JDK8-HashMap/" title="JDK8 HashMap源码"><img src="https://fangchenyong.oss-cn-hangzhou.aliyuncs.com/BEF238F4E59CF4D91A694FE9C5DBC030.JPG" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="JDK8 HashMap源码"/></a><div class="content"><a class="title" href="/2021/03/20/Java-%E6%BA%90%E7%A0%81-JDK8-HashMap/" title="JDK8 HashMap源码">JDK8 HashMap源码</a><time datetime="2021-03-19T16:00:00.000Z" title="发表于 2021-03-20 00:00:00">2021-03-20</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/03/13/The%20Road%20To%20Bald%20Man!/" title="The Road To Bald Man!"><img src="https://fangchenyong.oss-cn-hangzhou.aliyuncs.com/BEF238F4E59CF4D91A694FE9C5DBC030.JPG" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="The Road To Bald Man!"/></a><div class="content"><a class="title" href="/2021/03/13/The%20Road%20To%20Bald%20Man!/" title="The Road To Bald Man!">The Road To Bald Man!</a><time datetime="2021-03-12T16:00:00.000Z" title="发表于 2021-03-13 00:00:00">2021-03-13</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2020/07/21/%E6%A1%86%E6%9E%B6-Maven-%E9%85%8D%E7%BD%AE%E6%A0%87%E7%AD%BE%E8%AF%A6%E8%A7%A3/" title="Maven配置标签详解"><img src="https://fangchenyong.oss-cn-hangzhou.aliyuncs.com/BEF238F4E59CF4D91A694FE9C5DBC030.JPG" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Maven配置标签详解"/></a><div class="content"><a class="title" href="/2020/07/21/%E6%A1%86%E6%9E%B6-Maven-%E9%85%8D%E7%BD%AE%E6%A0%87%E7%AD%BE%E8%AF%A6%E8%A7%A3/" title="Maven配置标签详解">Maven配置标签详解</a><time datetime="2020-07-20T16:00:00.000Z" title="发表于 2020-07-21 00:00:00">2020-07-21</time></div></div></div></div></div></div></main><footer id="footer" style="background-image: url('https://fangchenyong.oss-cn-hangzhou.aliyuncs.com/BEF238F4E59CF4D91A694FE9C5DBC030.JPG')"><div id="footer-wrap"><div class="copyright">&copy;2019 - 2021 By 方陈勇</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text">人生没有退路！</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><div class="js-pjax"></div><script id="canvas_nest" defer="defer" color="0,0,255" opacity="0.7" zIndex="-1" count="99" mobile="false" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-nest.min.js"></script></div></body></html>